package com.abss.vote.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.abss.vote.model.GroupRule;

import java.util.List;

@Mapper
@Repository
public interface GroupRuleMapper {

    Integer addGroupRule(GroupRule groupRule);

    List<GroupRule> getAllGroupRules();

    @Select("select * from GROUP_RULE where ACTIVITY_ID=${activity_id} order by ID")
    List<GroupRule> getGroupRuleListByActivityId(@Param("activity_id")int activity_id);

    @Select("SELECT * from GROUP_RULE where ID=#{id}")
    GroupRule getGroupRuleByid(@Param("id")Integer id);

    @Select("SELECT GROUP_NAME from GROUP_RULE where ID=#{id}")
    String getGroupRuleName(@Param("id")Integer id);

    @Delete("delete from GROUP_RULE where ID=${id}")
    int deleteGroupRuleById(@Param("id")Integer id);
}
